import logging
import redis
import pymysql

pymysql.install_as_MySQLdb()

class Config(object):
    DEBUG = True
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/information"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # 开启数据库自动提交功能
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True
    SECRET_KEY = "EjpNVSNQTyGi1VvWECj9TvC/+kq3oujee2kdggsf8yCM6xX9Yjq52v54g+HVoknA"

    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    SESSION_TYPE = "redis" # 指定 session 保存到 redis 中
    SESSION_USE_SIGNER = True # 让 cookie 中的 session_id 被加密签名处理
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT) # 使用 redis 的实例
    PERMANENT_SESSION_LIFETIME = 86400 # session 的有效期，单位是秒

class DevelopmentConfig(Config):
    """开发模式的配置类"""
    DEBUG = True

    LOG_LEVEL = logging.DEBUG

class ProductionConfig(Config):
    DEBUG = False

    LOG_LEVEL = logging.ERROR

config_dict = {
    "development" : DevelopmentConfig,
    "production" : ProductionConfig

}